package com.cskaoyan.dbutils.handler;

import com.cskaoyan.bean.Account;
import com.cskaoyan.connectionpool.DruidUtils;
import com.cskaoyan.handler.MyResultSetHandler;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/03/24 11:26
 *
 * @author ciggar
 */
public class QueryRunnerDemo2 {

    static DataSource dataSource;

    static {
        dataSource = DruidUtils.getDataSource();
    }

    public static void main(String[] args) throws SQLException {


        // 有参构造
        QueryRunner queryRunner = new QueryRunner(dataSource);

        String sql = "select * from account";

        List<Account> accounts = queryRunner.query(sql, new MyResultSetHandler());

        System.out.println(accounts);

    }


}
